package com.example.back.mapper;

import com.example.back.model.Admin;
import com.example.back.model.Employee;
import com.example.back.model.Record;
import com.example.back.model.Room;
import org.apache.ibatis.annotations.*;

import java.sql.Date;
import java.util.List;

@Mapper
public interface AdminMapper {
    @Select("select * from admin")
    public List<Admin> findAllAdmin();
    @Select("select * from admin where account=#{account}")
    public Admin findByAccount(String account);
    @Select("select count(*) from user")
    public String userCount();
    @Select("select count(*) from the_order")
    public String orderCount();
    @Select("select * from employee")
    public List<Employee> selectAllEmployee();
    @Select("select * from employee where concat(name, phone, job) like concat('%', #{information}, '%')")
    public List<Employee> selectByInformation(String information);
    @Insert("insert into employee(name, sex, birthday, phone, job, state) values(#{name}, #{sex}, #{birthday}, #{phone}, #{job}, '001')")
    public Boolean insertEmployee(String name, int sex, Date birthday, String phone, String job);
    @Update("update employee set job=#{job} where employeeID=#{employeeID}")
    public Boolean updateEmployeeJob(int employeeID, String job);
    @Delete("delete from employee where employeeID=#{employeeID}")
    public Boolean deleteEmployee(int employeeID);
    @Select("select * from into_room")
    public List<Record> selectAllInto_room();
    @Select("select * from into_room where name=#{name}")
    public List<Record> findInto_roomByRoom(String name);
    @Select("select * from into_room where account=#{account}")
    public List<Record> findInto_roomByAccount(String account);
    @Select("select * from into_room where flag=#{flag}")
    public List<Record> findInto_roomByFlag(int flag);
    @Delete("delete from into_room where id=#{id}")
    public Boolean deleteRecordByID(int id);
    @Select("select flag from into_room where id=#{id}")
    public int findFlagByID(int id);
    @Select("select name from into_room where id=#{id}")
    public String findNameByID(int id);
    @Update("update into_room set flag=2, playTime=#{playTime} where id=#{id}")
    public Boolean updateRecordPlayByID(int id, String playTime);
    @Update("update into_room set flag=0, leaveTime=#{leaveTime} where id=#{id}")
    public Boolean updateRecordLeaveByID(int id, String leaveTime);
    @Select("select * from into_room left join room on into_room.name=room.name where into_room.name=#{name} and into_room.flag!=0")
    public Room findRoomByUser(String name);
}
